///////////////////////////////////////////////////////////////////////
// File:	MessageSystem.h													 
//																	 
// Author: Roberto Rubiano											 
//																	 
// Purpose: A system that will handle processing messages				 
///////////////////////////////////////////////////////////////////////
#ifndef MESSAGESYSTEM_H
#define MESSAGESYSTEM_H

#include "Messages.h"
#include <queue>
using std::queue;
#include "../Globals.h"

typedef void (*MESSAGEPROC)(CBaseMessage*);

class MessageSystem
{
private:
	queue<CBaseMessage*>	m_MSGQ;		   //	Stores my messages.
	MESSAGEPROC				m_MSGPROC;	   //	Points to user defined function.

	MessageSystem()		{}
	// Trilogy of Evil
	MessageSystem(const MessageSystem&);
	~MessageSystem() {};
	MessageSystem& operator=(const MessageSystem&);

public:

	static MessageSystem* GetInstance(void)
	{
		static MessageSystem Instance;
		return &Instance;
	}

	//	How many messages waiting to be processed.
	int GetNumMessages(void) { return (int)m_MSGQ.size(); }

	//	Setup the function pointer for our messages.
	void InitMessageSystem(MESSAGEPROC pMsgProc);

	//	Sends the message into the queue and awaits processing later on through
	//	The ProcessMessages() function.
	void SendMsg(CBaseMessage* pMsg);

	//	Processes all the messages that are waiting inside of the queue.
	//	Normally you only call this function once per frame.
	void ProcessMessages(void);

	//	Clears any messages that may be remaining
	void ClearMessages(void);

	//	Clears any messages that may be remaining and sets the function pointer to NULL.
	void ShutdownMessageSystem(void);

};

#endif